public class LeetCode28 {
    public int strStr(String haystack, String needle) {
        char[] text = haystack.toCharArray();
        char[] pattern = needle.toCharArray();
        int h = text.length;
        int n = pattern.length;
        for (int i = 0; i < h; i++) {
            boolean match = true;
            for (int j = 0; j < n; j++) {
                if (text[i] != pattern[j]) {
                    match = false;
                }
            }
            if (match) {
                return i;
            }
        }
        return -1;
    }
}
